<?php
/*
 * @Descripttion: 
 * @version: 1.0
 * @Author: Sam
 * date: 2021-06-03 15:08:37
 * @LastEditors: Sam
 * @LastEditTime: 2021-12-09 21:54:18
 */
namespace app\admin\model;
use think\Model;

class Notice extends BaseModel {
    
    protected $name = 'notice';
    protected $autoWriteTimestamp = true;

 
    public function getCreateTimeAttr($value){
    	return date('Y-m-d H:i',$value);
    }


    public function type(){
        return $this->belongsTo(NoticeType::class,'type')->bind(['type_text'=>'title']);
    }



    public function getDetailAttr($value){
        return html_entity_decode(html_entity_decode($value));
    }

    public function getFilesAttr($value){
        return \html_entity_decode($value);
    }

    public function getAttachFileAttr($value,$data){
        return $data['attach'] ? Attach::where('id','in',$data['attach'])->field('title,file,thumb')->select() : [];
    }


}
